package icu.ac.kr.phonebook.activity;


import network.NetworkModule;
import icu.ac.kr.phonebook.*;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;


public class SecretDiaryMain extends Activity {

	static final String TAG = "SecretDiaryMain";

	
	NetworkModule network;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.diarymain);
	
		((Button) findViewById(R.id.btn1)).setOnClickListener(mClicklistener);
		((Button) findViewById(R.id.btn2)).setOnClickListener(mClicklistener);	
	
		network = new NetworkModule(this);
		String address = NetworkModule.getLocalIpAddress();
		int myNumber = 777; // get my number
		network.connectToServer(myNumber, address, "POST");
		Log.d(TAG,"---------------------");
		network.runServer();
		Log.d(TAG,"---------------------");
	}
	
	
	
	
	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		network.stopServer();
	
	}




	Button.OnClickListener mClicklistener = new Button.OnClickListener(){

		public void onClick(View v) {
			// TODO Auto-generated method stub
			
			switch(v.getId())
			{
			case R.id.btn1:
				Intent intent = new Intent(SecretDiaryMain.this, RegisterScheduleActivity.class);
				startActivityForResult(intent, 0);
				//finish();
				break;
			case R.id.btn2:
				Intent intent2 = new Intent(SecretDiaryMain.this, SeachScheduleActivity.class);
				startActivityForResult(intent2, 0);
				//finish();
				break;
			}
			
		}
		
		
	};

	
	
	
	
}
